package complex.java.serialize;

import org.codehaus.jackson.map.ObjectMapper;

/**
 * 使用json序列化反序列化
 * 
 * @author ymkyve
 * 
 */
public class JsonSerializable implements ISerializable {
	private static ObjectMapper objectMapper = new ObjectMapper();

	@Override
	public void serialize(Order order) throws Exception {
		System.out
				.println("=================JsonSerializable============================");
		long start = System.currentTimeMillis();
		String str = objectMapper.writeValueAsString(order);
		long serialize = System.currentTimeMillis();
		Order order1 = objectMapper.readValue(str, Order.class);
		long deSerialize = System.currentTimeMillis();
		// System.out.println(order1);
		System.out.println("serialize:" + (serialize - start));
		System.out.println("deSerialize:" + (deSerialize - serialize));
	}
}
